var utils = require('../../../utils/util.js')
var c = require('../../../utils/config.js')
Page({

    /**
     * 页面的初始数据
     */
    data: {
      slide: [],
      img_url: c.img_url,
      vipconfig: [],
      content: "",
      select: 0,
      level_id:"",
      need_money:0.00,
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
      var that = this;
      var token = wx.getStorageSync("userinfo").wap_token;
      var data = {
        url: "/zfcom/slide/lists",
        cat_id: 15,
        keyword: "",
        page: 1,
        limit: 1
      };
      utils.request(data).then(function (res) {
        if (res.code == 0) {
          var data = res.data;
          that.setData({
            slide: data,
          });
        } else {

        }
      });

      var data = {
        url: "/zfshop/userlevelconfig/lists",
        token: token,
      };
      utils.request(data).then(function (res) {
        if (res.code == 0) {
          var data = res.data;
          // var vipconfig = [];
          // for (let i = 1; i<data.length;i++){
          //   vipconfig.push(data[i]);
          // }
          that.setData({
            vipconfig: data,
            level_id: data[0].id,
            need_money: data[0].money,
            content:data[0].content,
          });
          
        } else {

        }
      });
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    },
    Tab_list: function (e) {
        let k = e.currentTarget.dataset.index;
        let id = e.currentTarget.dataset.id;
        let money = e.currentTarget.dataset.money;
        let content = e.currentTarget.dataset.content;
        this.setData({
            select: k,
            level_id: id,
            need_money: money,
            content:content,
        })
    },
    uplevel:function(){
      wx.navigateTo({
        url: '/pages/cloudshop/upgrade/pay/index?level_id=' + this.data.level_id + '&need_money=' + this.data.need_money
      })
    }
})